function poll(){
	console.log('poll');
    $.ajax({ 
    	url: 'server/poll.php',
    	async:true,
    	cache:false,
    	timeout: 20000,
    	success: function(data){
    		log(data);
    		 setTimeout(poll,1000);
    		 /* Request next message after 1 second */
    	},
    	error: function(xhr, textStatus, errorThrown){
            log("Error : ", textStatus + " (" + errorThrown + ")");
            setTimeout(poll,5000); /* Try again after 5 seconds */
        }
    });
}

function log(msg)
{
	$("#console").append(msg+"<br>");
}